package com.pw.study.actors

import akka.actor.{Actor, ActorRef, ActorSystem, Props}

/**
 * @Desc: TODO
 * @author: future
 * @since: 2022/5/22-9:58
 */
object SayHello {
  def main(args: Array[String]): Unit = {
    //1.创建一个ActorSystem
    val actorFactory: ActorSystem = ActorSystem("actorFactory")
    //2.通过actorFactory
    val sayActor: ActorRef = actorFactory.actorOf(Props[SayHelloActor], "SayHelloActor")
    sayActor ! "start"
    sayActor ! "美女你好"
  }
}

class SayHelloActor extends Actor {
  override def receive: Receive = {
    case "start" => println("start.....")
    case "hello" => println("hello......")
    case "girl" => println("girl")
    case "exit" => {
      println("stop-----start")
      context.stop(self)
      println("stop-----end")
      context.system.terminate()
    }
    case _ => println("other......ll")


  }
}
